package com.yirui.serialcomm.service;

import com.yirui.serialcomm.core.protocol.Context;
import com.yirui.serialcomm.core.protocol.PortAllocator;
import com.yirui.serialcomm.core.protocol.SimplePortAllocator;
import lombok.Data;

/**
 * @author Dujie
 * @create 2025/8/13
 * @since 1.0.0
 */
@Data
public class ServerContext implements Context {
    private String targetIp;
    private int udpPort;
    private int tcpPort;
    private PortAllocator portAllocator;

    public PortAllocator getPortAllocator(){
        if(portAllocator == null){
            portAllocator = new SimplePortAllocator(this, 1);
        }
        return portAllocator;
    }
}
